{extend name="public/base" /}
{block name="content"}
<ol class="breadcrumb">
    导航位置：<li><a href="#">投稿</a></li>
</ol>
<div class="tougao">
    <form action="">
        <input type="hidden" name="author" value="{:session('index.nickname')}">
        <div class="form-group">
            <label for="title" class="control-label">标题</label>
            <input type="text" class="form-control" id="title" name="title" placeholder="文章标题">
        </div>
        <div class="form-group">
            <label for="tags" class="control-label">标签</label>
            <input type="text" class="form-control" id="tags" name="tags" placeholder="用逗号分隔">
            <span class="help-block">用竖线|分隔</span>
        </div>
        <div class="form-group">
            <label for="cateid" class="control-label">所属导航</label>
            <select name="cateid" id="cateid" class="form-control">
                <option value="">请选择</option>
                {volist name="cates" id="vo"}
                <option value="{$vo.id}">{$vo.catename}</option>
                {/volist}
            </select>
        </div>
        <div class="form-group">
            <label for="desc" class="control-label">文章概要</label>
            <textarea name="desc" id="desc" cols="30" rows="5" class="form-control"></textarea>
        </div>
        <div class="form-group">
            <label for="content" class="control-label">内容</label>
            <textarea name="content" id="content" cols="30" rows="10"></textarea>
        </div>
        <div class="form-group">
            <button class="btn btn-primary" id="postArticle">投稿</button>
        </div>
    </form>
</div>
{/block}

{block name="js"}
<script src="/static/lib/ueditor/ueditor.config.js"></script>
<script src="/static/lib/ueditor/ueditor.all.js"></script>
<script>
    $(function () {
        UE.getEditor('content');

        $('#postArticle').click(function () {
            $.ajax({
                url:"{:url('index/article/post')}",
                type:'post',
                data:$('form').serialize(),
                dataType:'json',
                success:function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {
                            icon:6,
                            time:2000
                        }, function () {
                            location.href = data.url;
                        });
                    }else {
                        layer.open({
                            title:'投稿失败',
                            content:data.msg,
                            icon:5,
                            anim:6
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
{/block}